#include <iostream>
#include <vector>
#include <list>
#include <string>
using namespace std;

// template <typename T>
// class Less_than
// {
//     const T val; // 待比较的值
// public:
//     Less_than(const T &v) : val(v) {}
//     bool operator()(const T &x) const { return x < val; } // 调用运算符
// };

template <typename C, typename P>
int count(const C &c, P pred)
{
    int cnt = 0;
    for (const auto &x : c)
        if (pred(x))
            ++cnt;
    return cnt;
}

void f(const vector<int> &vec, const list<string> &lst, int x, const string &s)
{
    cout << "number of values less than " << x
         << " : " << count(vec, [&](int a)
                           { return a < x; })
         << "\n";
    cout << "number of values less than " << s
         << " : " << count(lst, [&](const string &a)
                           { return a < s; })
         << "\n";
}

int main(int argc, char const *argv[])
{
    vector<int> ivec{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    list<string> svec{"sldkf", "sdkfj", "asd", "zdfoi", "yskdj"};
    f(ivec, svec, 5, "dslkdf");
    return 0;
}
